<!-- Begin: cppage - Create Ad -->
<div class="cppage product">
    <div class="header">
        <?
        $disabled = '';
        if (CPanel::$products_ad == null) {
            ?>
            <h2>Cadastrar um novo anúncio</h2>
            <?
        } else {
            $disabled = ' disabled';
            ?>
            <h2>Alterar anúncio</h2>
        <? } ?>
    </div>
    <div class="alert-msg">Caro usuário, toda alteração realizado no anúncio será verificada por nossa equipe, caso seja constatada alguma irregularidade seu anúncio poderá ser bloqueado sem prévio aviso!</div>
    <form id="product">
        <div class="categorie">
            <label>Categoria:</label>
            <select class="input required" id="category" name="category" title="Categoria">
                <option value=""></option>
                <? foreach (CPanel::$products_categories as $cat) { ?>
                    <option value="<?= $cat->id; ?>" <? if (CPanel::$products_ad->id_category == $cat->id) { ?> selected="selected" <? } ?>  ><?= $cat->name; ?></option>
                <? } ?>
            </select>
        </div>
        <div class="name">
            <label>Produto:</label>
            <input class="input required" type="text" name="name" maxlength="30" value="<?= CPanel::$products_ad->p_name ?>" title="Nome">
        </div>
        <div class="price">
            <label>Preço* :</label>
            <input class="input required" type="text" name="price" maxlength="21" value="<?= Util::format_money(CPanel::$products_ad->p_price) ?>" title="Preço">
        </div>
        <div class="description">
            <label>Descrição:</label>
            <textarea name="description" class="input" title="Descriçao"><?= CPanel::$products_ad->p_description ?></textarea>
        </div>

        <h2>Fotos do Produto</h2>
        <ul class="pictures">
            <?
            if (CPanel::$products_ad != null) {
                $pictures = DbGet::products_pictures(CPanel::$products_ad->p_id);
                ?>
                <input type="hidden" name="pictures-excluded">
            <? } ?>
            <li>
                <? if (!isset($pictures[0])) { ?>
                    <img src="<?= _IMG_ ?>white.jpg" alt="Foto 1" />
                    <input type="file" name="pictures[]">
                <? } else { ?>
                    <img src="<?= _PDT_URI_ . 'last-updated/' . $pictures[0]->p_filepicture ?>" data-original="<?= _IMG_ ?>white.jpg" alt="Foto 1" />
                    <input type="file" name="pictures[]" disabled>
                    <a class="del" href="javascript:;" data="<?= $pictures[0]->p_id ?>"></a>
                <? } ?>
            </li>
            <li>
                <? if (!isset($pictures[1])) { ?>
                    <img src="<?= _IMG_ ?>white.jpg" alt="Foto 2" />
                    <input type="file" name="pictures[]">
                <? } else { ?>
                    <img src="<?= _PDT_URI_ . 'last-updated/' . $pictures[1]->p_filepicture ?>" data-original="<?= _IMG_ ?>white.jpg" alt="Foto 2" />
                    <input type="file" name="pictures[]" disabled>
                    <a class="del" href="javascript:;" data="<?= $pictures[1]->p_id ?>"></a>
                <? } ?>
            </li>
            <li>
                <? if (!isset($pictures[2])) { ?>
                    <img src="<?= _IMG_ ?>white.jpg" alt="Foto 3" />
                    <input type="file" name="pictures[]">
                <? } else { ?>
                    <img src="<?= _PDT_URI_ . 'last-updated/' . $pictures[2]->p_filepicture ?>" data-original="<?= _IMG_ ?>white.jpg" alt="Foto 3" />
                    <input type="file" name="pictures[]" disabled>
                    <a class="del" href="javascript:;" data="<?= $pictures[2]->p_id ?>"></a>
                <? } ?>
            </li>
        </ul>
        <? if (CPanel::$products_ad != null) { ?>
            <input type="hidden" name="id" value="<?= CPanel::$products_ad->p_id ?>">
        <? } ?>
        <input class="submit" type="submit" value="Salvar">
    </form>
</div> <!-- End -->
